package com.api.sw.duban.web;

import com.alibaba.fastjson.JSONObject;
import com.api.sw.duban.action.DubanTpAction;
import com.api.sw.duban.action.DubanqsAction;
import com.api.sw.duban.util.CacheUtil;
import com.api.sw.duban.util.DubUtil;
import com.api.sw.duban.util.LogTool;
import com.engine.common.util.ParamUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import java.util.HashMap;
import java.util.Map;

/*
    决策督察
 */
@Path("/dubanjc")
public class DbanTpAction {
    private final static LogTool log = new LogTool("/log/duban/",false);

        //获取查询列表数据页面
    @GET
    @Path("/getCheckTpJan")
    @Produces({"text/plain"})
    public String getCheckTpJan(@Context HttpServletRequest request, @Context HttpServletResponse response){
        JSONObject json=new JSONObject();
        boolean flag=false;
        try {
            User user = HrmUserVarify.getUser(request, response);
            DubanTpAction DubanqsAction=new DubanTpAction();
            flag=DubanqsAction.getCheckTpJan(ParamUtil.request2Map(request),user);
        }catch (Exception e) {
            e.printStackTrace();

        }
        json.put("flag",flag);
        return JSONObject.toJSONString(json);
    }
    //获取查询列表数据页面
    @GET
    @Path("/tptablelist")
    @Produces({"text/plain"})
    public String getQstablelist(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanTpAction DubanqsAction=new DubanTpAction();
            apidatas.putAll(DubanqsAction.getTpTablelist(ParamUtil.request2Map(request),user));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }
    //获取查询列表数据页面
    @GET
    @Path("/qscondition")
    @Produces({"text/plain"})
    public String getQscondition(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanqsAction DubanqsAction=new DubanqsAction();
            apidatas.putAll(DubanqsAction.getCondition(ParamUtil.request2Map(request),user));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }
    //检测是否可以编辑 删除 交办等操作
    @GET
    @Path("/checkButton")
    @Produces({"text/plain"})
    public String checkButton(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        JSONObject json=new JSONObject();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanqsAction DubanqsAction =new DubanqsAction();
            json=DubanqsAction.checkButton(ParamUtil.request2Map(request),user);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(json);
    }
    //获取收发文部门对应的督查人员
    @GET
    @Path("/getDcryByReceiveunit")
    @Produces({"text/plain"})
    public String getDcryByReceiveunit(@Context HttpServletRequest request, @Context HttpServletResponse response){
        JSONObject json=new JSONObject();
        String Receiveunit=Util.null2String(request.getParameter("Receiveunitid"));
        String receiveunitry= Util.null2String(DubUtil.getDcryByReceiveunit(Receiveunit));
        json.put("receiveunitry",DubUtil.getHrmspecialobj(receiveunitry));
        return JSONObject.toJSONString(json);
    }

}
